
#ifndef __QUANTITY_H__
#define __QUANTITY_H__

#include <Format.h>

using namespace std;

template <class TUnit>
class Quantity
{
public:
	Quantity(unsigned int value, const TUnit& unitType):value_m(value),unitType_m(unitType)
	{
	}
	unsigned int toBase() const
	{
		return unitType_m.toBase(value_m);
	}
 	bool operator == (const Quantity & rhs) const
	{
		return (toBase() == rhs.toBase());
	}
 	Quantity operator = (const Quantity & rhs) const
	{		
		return Quantity(rhs.value_m, rhs.unitType_m);
	}
	
	Quantity operator + (const Quantity & rhs) const
	{
		return Quantity(toBase()+rhs.toBase(),TUnit::getBaseUnit());
	}	
	void formatOutput(ostream& sio, Format& format) const
	{
		format.output(sio,toBase());
	}
private:
	unsigned int value_m;
	const TUnit& unitType_m;
};

#endif

